package com.lkd.controller;

import com.lkd.dto.SkuClassDto;
import com.lkd.entity.SkuClass;
import com.lkd.result.PageBean;
import com.lkd.result.Result;
import com.lkd.service.SkuClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//分类管理
@RestController
public class SkuClassController {

    @Autowired
    private SkuClassService skuClassService;

    //分页查询
    @GetMapping("/api/vm-service/skuClass/search")
    public Result findByPage(SkuClassDto skuClassDto){
        PageBean pageBean = skuClassService.findByPage(skuClassDto);
        return Result.success(pageBean);
    }

    //新增
    @PostMapping("/api/vm-service/skuClass")
    public Result save(@RequestBody SkuClass skuClass){
        Boolean result = skuClassService.save(skuClass);
        return Result.success(result);
    }

    //主键查询
    @GetMapping("/api/vm-service/skuClass/{classId}")
    public Result findById(@PathVariable("classId") Long classId){
        SkuClass skuClass = skuClassService.findById(classId);
        return Result.success(skuClass);
    }


    //修改
    @PutMapping("/api/vm-service/skuClass")
    public Result update(@RequestBody SkuClass skuClass){
        Boolean result = skuClassService.update(skuClass);
        return Result.success(result);
    }

    //主键删除
    @DeleteMapping("/api/vm-service/skuClass/{classId}")
    public Result deleteById(@PathVariable("classId") Long classId){
        Boolean result = skuClassService.deleteById(classId);
        return Result.success(result);
    }

}
